package com.xin.springclouduser.converter;

import com.xin.springclouduser.dataobject.User;
import com.xin.springclouduser.form.UserForm;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

public class UserForm2UserConverter {
    public static User convert(UserForm userForm) {
        User user = new User();
        BeanUtils.copyProperties(userForm, user);
        return user;
    }

    public static List<User> convert(List<UserForm> userForms){
          return userForms.stream().map(e -> convert(e)).collect(Collectors.toList());
    }
}
